<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>知识社区 - 简洁版</title>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet">
    <style>
        :root {
            --primary-color: #2A2A72;
            --secondary-color: #009FFD;
            --accent-color: #FFA400;
            --text-color: #2C3E50;
            --bg-color: #f5f7fa;
            --card-bg: white;
            transition: all 0.3s ease;
        }

        [data-theme="dark"] {
            --primary-color: #6C63FF;
            --secondary-color: #4A90E2;
            --accent-color: #FF8966;
            --text-color: #E0E0E0;
            --bg-color: #1A1A1A;
            --card-bg: #2D2D2D;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Poppins', sans-serif;
        }

        body {
            background: var(--bg-color);
            color: var(--text-color);
            min-height: 100vh;
            transition: background 0.3s ease;
        }

        /* 加载动画 */
        .loader {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: var(--bg-color);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 9999;
            opacity: 1;
            transition: opacity 0.5s;
        }

        .spinner {
            width: 50px;
            height: 50px;
            border: 5px solid rgba(0, 0, 0, 0.1);
            border-radius: 50%;
            border-top-color: var(--secondary-color);
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        /* 导航栏 */
        .nav-container {
            position: fixed;
            top: 0;
            width: 100%;
            background: rgba(var(--card-bg), 0.95);
            backdrop-filter: blur(10px);
            z-index: 1000;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        }

        nav {
            max-width: 1200px;
            margin: 0 auto;
            padding: 1.5rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .nav-links {
            display: flex;
            gap: 2rem;
        }

        .nav-link {
            color: var(--text-color);
            text-decoration: none;
            font-weight: 500;
            position: relative;
            padding: 0.5rem;
            transition: all 0.3s ease;
        }

        .nav-link::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 0;
            height: 2px;
            background: var(--secondary-color);
            transition: width 0.3s ease;
        }

        .nav-link:hover::after {
            width: 100%;
        }

        /* 主内容区 */
        main {
            margin-top: 100px;
            padding: 2rem;
        }

        section {
            max-width: 1200px;
            margin: 4rem auto;
            opacity: 0;
            transform: translateY(20px);
            transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
        }

        section.visible {
            opacity: 1;
            transform: translateY(0);
        }

        h2 {
            margin-bottom: 2rem;
            font-size: 2rem;
            position: relative;
            padding-left: 1rem;
        }

        h2::after {
            content: '';
            position: absolute;
            left: 0;
            bottom: -5px;
            width: 50px;
            height: 3px;
            background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
        }

        /* 卡片系统（简化版） */
        .card-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 2rem;
            padding: 2rem 0;
        }

        .card {
            background: var(--card-bg);
            border-radius: 15px;
            padding: 1.5rem;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }

        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
        }

        .card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 4px;
            background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .card:hover::before {
            opacity: 1;
        }

        /* 问答卡片特殊样式 */
        .question-card {
            padding-left: 2.5rem;
        }

        .question-card::after {
            content: 'Q';
            position: absolute;
            left: 1rem;
            top: 1.2rem;
            color: var(--accent-color);
            font-size: 1.8rem;
            font-weight: 700;
        }

        .meta {
            margin-top: 1rem;
            font-size: 0.9rem;
            color: var(--secondary-color);
        }

        /* 主题切换按钮 */
        .theme-toggle {
            position: fixed;
            bottom: 30px;
            right: 30px;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background: var(--secondary-color);
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
            transition: all 0.3s ease;
            border: none;
            font-size: 1.2rem;
        }

        .theme-toggle:hover {
            transform: scale(1.1);
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .card-grid {
                grid-template-columns: 1fr;
            }
          
            nav {
                flex-direction: column;
                gap: 1rem;
            }

            h2 {
                font-size: 1.5rem;
            }
        }
    </style>
</head>
<body>
    <div class="loader">
        <div class="spinner"></div>
    </div>

    <div class="nav-container">
        <nav>
            <h1>知识社区</h1>
            <div class="nav-links">
                <a href="#blog" class="nav-link">博客文章</a>
                <a href="#qa" class="nav-link">问答社区</a>
            </div>
        </nav>
    </div>

    <main>
        <section id="blog">
            <h2>最新文章</h2>
            <div class="card-grid"></div>
        </section>

        <section id="qa">
            <h2>热门问答</h2>
            <div class="card-grid"></div>
        </section>
    </main>

    <button class="theme-toggle">🌓</button>

    <script>
        // 模拟数据
        const mockData = {
            blogs: [
                {
                    title: '前端框架对比分析',
                    content: '深度解析Vue、React和Angular的核心差异与应用场景...',
                    date: '2023-08-20',
                    readTime: '12分钟阅读'
                },
                {
                    title: 'CSS新特性实践指南',
                    content: 'Container Queries与Layer新特性的实际应用案例...',
                    date: '2023-08-19',
                    readTime: '8分钟阅读'
                },
                {
                    title: 'Web性能优化策略',
                    content: '从加载到渲染的全链路性能优化方案...',
                    date: '2023-08-18',
                    readTime: '15分钟阅读'
                }
            ],
            questions: [
                {
                    title: '如何实现完美响应式布局？',
                    content: '讨论现代响应式设计的最佳实践方案...',
                    answers: 28,
                    lastActive: '2小时前'
                },
                {
                    title: 'TypeScript最佳实践',
                    content: '如何高效使用TypeScript进行大型项目开发？',
                    answers: 45,
                    lastActive: '4小时前'
                },
                {
                    title: '前端工程化方案',
                    content: '现代前端项目的基础设施建设指南...',
                    answers: 33,
                    lastActive: '6小时前'
                }
            ]
        };

        // 初始化
        document.addEventListener('DOMContentLoaded', async () => {
            // 模拟数据加载
            await new Promise(resolve => setTimeout(resolve, 1500));
          
            // 隐藏加载动画
            document.querySelector('.loader').style.opacity = '0';
            setTimeout(() => {
                document.querySelector('.loader').style.display = 'none';
            }, 500);

            // 渲染内容
            renderCards('#blog .card-grid', mockData.blogs, createBlogCard);
            renderCards('#qa .card-grid', mockData.questions, createQuestionCard);
            initInteractions();
            initTheme();
        });

        // 卡片模板
        function createBlogCard(data) {
            return `
                <div class="card">
                    <h3>${data.title}</h3>
                    <p>${data.content}</p>
                    <div class="meta">${data.date} · ${data.readTime}</div>
                </div>
            `;
        }

        function createQuestionCard(data) {
            return `
                <div class="card question-card">
                    <h3>${data.title}</h3>
                    <p>${data.content}</p>
                    <div class="meta">${data.answers}个回答 · 最新回复${data.lastActive}</div>
                </div>
            `;
        }

        // 渲染卡片
        function renderCards(selector, data, template) {
            const container = document.querySelector(selector);
            container.innerHTML = data.map(template).join('');
        }

        // 初始化交互
        function initInteractions() {
            // 滚动动画
            const observer = new IntersectionObserver((entries) => {
                entries.forEach(entry => {
                    if (entry.isIntersecting) {
                        entry.target.classList.add('visible');
                    }
                });
            }, { threshold: 0.1 });

            document.querySelectorAll('section').forEach(section => {
                observer.observe(section);
            });

            // 平滑滚动
            document.querySelectorAll('a[href^="#"]').forEach(anchor => {
                anchor.addEventListener('click', function(e) {
                    e.preventDefault();
                    const target = document.querySelector(this.getAttribute('href'));
                    target.scrollIntoView({
                        behavior: 'smooth',
                        block: 'start'
                    });
                });
            });

            // 主题切换
            document.querySelector('.theme-toggle').addEventListener('click', toggleTheme);
        }

        // 主题功能
        function initTheme() {
            const savedTheme = localStorage.getItem('theme') || 'light';
            document.documentElement.setAttribute('data-theme', savedTheme);
        }

        function toggleTheme() {
            const currentTheme = document.documentElement.getAttribute('data-theme');
            const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
            document.documentElement.setAttribute('data-theme', newTheme);
            localStorage.setItem('theme', newTheme);
        }
    </script>
</body>
</html>